package cn.sixos.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.forten.utils.system.CurrentTimeKeyBuilder;

@Entity
@Table(name = "TEST_COURSE")
public class Course implements Serializable {
	private static final long serialVersionUID = 5724857558620948946L;
	@Id
	private long id;
	@Column
	private String courseName;
	@Column
	private String teachTime;
	@Column
	private String teachPlace;
	@Column
	private String teacher;
	@Column
	private String mainTeacher;
	@Column
	private String mainTeacherEmail;
	@Column
	private String courseType;
	@Column
	private int courseVolume;
	@Column
	private int courseCredit;
	@Column
	private Date startTime;
	@Column
	private Date endTime;
	@Column
	private String courseText;
	@ManyToMany(mappedBy = "courseSet")
	private Set<User> userSet;

	public Course() {
		super();
		this.id = CurrentTimeKeyBuilder.getInstance().nextPK();
		this.userSet = new HashSet<User>();
	}

	public Course(String courseName, String teachTime, String teachPlace,
			String teacher, String mainTeacher, String mainTeacherEmail,
			String courseType, int courseVolume, int courseCredit,
			Date startTime, Date endTime, String courseText) {
		this();
		this.courseName = courseName;
		this.teachTime = teachTime;
		this.teachPlace = teachPlace;
		this.teacher = teacher;
		this.mainTeacher = mainTeacher;
		this.mainTeacherEmail = mainTeacherEmail;
		this.courseType = courseType;
		this.courseVolume = courseVolume;
		this.courseCredit = courseCredit;
		this.startTime = startTime;
		this.endTime = endTime;
		this.courseText = courseText;
	}

	public String getCourseName() {
		return courseName;
	}

	public void setCourseName(String courseName) {
		this.courseName = courseName;
	}

	public String getTeachTime() {
		return teachTime;
	}

	public void setTeachTime(String teachTime) {
		this.teachTime = teachTime;
	}

	public String getTeachPlace() {
		return teachPlace;
	}

	public void setTeachPlace(String teachPlace) {
		this.teachPlace = teachPlace;
	}

	public String getTeacher() {
		return teacher;
	}

	public void setTeacher(String teacher) {
		this.teacher = teacher;
	}

	public String getMainTeacher() {
		return mainTeacher;
	}

	public void setMainTeacher(String mainTeacher) {
		this.mainTeacher = mainTeacher;
	}

	public String getMainTeacherEmail() {
		return mainTeacherEmail;
	}

	public void setMainTeacherEmail(String mainTeacherEmail) {
		this.mainTeacherEmail = mainTeacherEmail;
	}

	public String getCourseType() {
		return courseType;
	}

	public void setCourseType(String courseType) {
		this.courseType = courseType;
	}

	public int getCourseVolume() {
		return courseVolume;
	}

	public void setCourseVolume(int courseVolume) {
		this.courseVolume = courseVolume;
	}

	public int getCourseCredit() {
		return courseCredit;
	}

	public void setCourseCredit(int courseCredit) {
		this.courseCredit = courseCredit;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public String getCourseText() {
		return courseText;
	}

	public void setCourseText(String courseText) {
		this.courseText = courseText;
	}

	public Set<User> getUserSet() {
		return userSet;
	}

	public void setUserSet(Set<User> userSet) {
		this.userSet = userSet;
	}

	public long getId() {
		return id;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Course other = (Course) obj;
		if (id != other.id)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Course [id=" + id + ", courseName=" + courseName
				+ ", teachTime=" + teachTime + ", teachPlace=" + teachPlace
				+ ", teacher=" + teacher + ", mainTeacher=" + mainTeacher
				+ ", mainTeacherEmail=" + mainTeacherEmail + ", courseType="
				+ courseType + ", courseVolume=" + courseVolume
				+ ", courseCredit=" + courseCredit + ", startTime=" + startTime
				+ ", endTime=" + endTime + ", courseText=" + courseText
				+ ", userSet=" + userSet + "]";
	}

}
